<template>
  <el-dialog title="提示" :visible="operatePup" :before-close="close">
    <el-form ref="form" :rules="rules" :model="form" label-width="80px">
      <el-form-item label="角色名称" prop="name">
        <el-input v-model="form.name" />
      </el-form-item>
      <el-form-item label="角色描述" prop="description">
        <el-input v-model="form.description" />
      </el-form-item>
    </el-form>
    <template #footer>
      <el-row type="flex" justify="center">
        <el-row :span="6">
          <el-button size="small" @click="close">取 消</el-button>
          <el-button size="small" type="primary" @click="confirm">
            确 定
          </el-button>
        </el-row>
      </el-row>
    </template>
  </el-dialog>
</template>

<script>
import { getRoleDetail, editRoleDetail } from '@/api/setting'
export default {
  name: 'OperateRolePup',
  props: {
    operatePup: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      form: {},
      rules: {
        name: [{ required: true, message: '请输入活动名称', trigger: 'blur' }]
      }
    }
  },
  created() {},
  methods: {
    close() {
      this.$emit('close')
      this.$refs.form.resetFields()
      this.from = {
        name: '',
        description: ''
      }
    },
    async confirm() {
      try {
        await editRoleDetail(this.form)
        this.$message('编辑角色成功')
        this.$emit('editRoles')
      } catch (err) {
        this.$message('编辑角色失败')
      }
    },
    async getRoleDetail(id) {
      const res = await getRoleDetail(id)
      this.form = res
    }
  }
}
</script>

<style></style>
